<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript" src="${staticPath}/js/decimalinput.js"></script>
<script type="text/javascript" src="${staticPath}/js/negotiation.js"></script>

<script type="text/javascript">

 $(function(){
	$("#amount").decimalinput();
 	$(".chosen-select").chosen({});
 	var deductCode = $("#deductCode").val();
 	var index = deductCode.indexOf('B');
 	if(index == 0){
		$("#assItemsCountBase").attr("disabled","disabled");
	}
 });
function chenageDeductCode(t,text,value){
	var index =value.indexOf('B');
	if(index == 0){
		$("#assItemsCountBase").attr("disabled","disabled");
	}else{
		$("#assItemsCountBase").removeAttr("disabled");
	}
	
	$("#deductItem").val(text.split('-')[0]);  
	var shopId=$("#storeId").val();
	$("#taxRateCode_items").FillOptions(Com_Parameter.ContextPath+"/sys/base/article/getSysBaseRateCode?itemNum="+value+"&shopId="+shopId,{datatype:"json",textfield:"articleName",valuefiled:"article",defValue:"${items.taxRateCode}"});
	
	$.ajax({
		type: "POST",
		url: "${contextPath}/sys/base/article/getSysBaseRateCode?itemNum="+value+"&shopId="+shopId,
		data: null,
		success: function(data) {
			var jsonObj =eval('(' + data + ')');
			 $.each(jsonObj, function(i,items){
				 $("#assItemsCountBase").val(items.salestype);
			 })
		}
	});
}

</script>
<div class="modal-dialog">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">&times;</button>
			<h4 class="modal-title">添加合同信息</h4>
		</div>
		<!-- /modal-header -->
		<form action="${contextPath}/biz/contract/assrecord/createAssassitems" method="post" id="paramForm">
			<div class="modal-body">
				<table class="table">
					<tr>
						<td>
							<div class="col-sm-12">
								<label for="isGuarantee_lab" class="col-sm-5 control-label">扣款项代码:</label>
								<ossp:select style="width:200px;" class_="chosen-select" id="deductCode" defaultSelected="${deductCode}"
									 onchange="chenageDeductCode(this,this.options[this.options.selectedIndex].text,this.options[this.options.selectedIndex].value)" 
									  service="selectArtictService?contractType=${contractType}" ></ossp:select>
							</div>
						</td>
						
						<td>
							<div class="col-sm-12">
								<label for="guaranteeType_lab" class="col-sm-5 control-label">扣款项:</label>
								<div class="col-sm-7">
									<input type="text" class="form-control required"
										id="deductItem" name="deductItem" value="${assitems.deductItem }" />
								</div>
							</div>
						</td>
					</tr>
					<tr>
						<td>	
							<div class="col-sm-12">
								<label for="deductRate_lab" class="col-sm-5 control-label">税率:</label>
								<div class=" input-group col-sm-7">
											<select onchange="taxRateChange(this,this.options[this.options.selectedIndex].text)" id="taxRateCode_items" class="form-control"> </select>
								</div>
							</div>
						</td>	
						<td>
							<div class="col-sm-12">
								<label for="validType_lab" class="col-sm-5 control-label">金额/比例:</label>
								<div class=" input-group col-sm-7">
									<input type="text" class="form-control required"
										id="amount" name="amount" value="${assitems.amount }" />
								</div>
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<div class="col-sm-12">
								<label for="lower_lab" class="col-sm-5 control-label">时效类型:</label>
								<div class="input-group col-sm-7">
									<ossp:select dictType="DEFEND_SYTLE" id="assItemsValidType" name="assItemsValidType" defaultSelected="20" class_="form-control required"></ossp:select>
								</div>
							</div>
						</td>
						<td>
							<div class="col-sm-12">
								<label for="upper_lab" class="col-sm-5 control-label">计算基数:</label>
								<div class=" input-group col-sm-7">
									<ossp:select dictType="COMPUTE_BASE" id="assItemsCountBase" name="assItemsCountBase" defaultSelected="${assitems.countBase }" class_="form-control required"></ossp:select>
								</div>
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<div class="col-sm-12">
								<label for="payDate_lab" class="col-sm-5 control-label">扣款方式:</label>
								<div class=" input-group col-sm-7">
									<ossp:select dictType="PAYMENT_TYPE" id="assItemsDeductType" name="assItemsDeductType" defaultSelected="10" class_="form-control required"></ossp:select>
								</div>
							</div>
						</td>
						<td>
							<div class="col-sm-12" style="display: none;">
								<label for="validType_lab" class="col-sm-5 control-label">扣款类型:</label>
								<div class=" input-group col-sm-7">
									<ossp:select dictType="DEDUCT_CATE" id="deductCate" name="deductCate" defaultSelected="${assitems.deductCate }" class_="form-control required"></ossp:select>
								</div>
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<div class="col-sm-12">
								<label for="updateBy" class="col-sm-5 control-label">开始日期:</label>
								<div class=" col-sm-7">
									<div class="input-group date startDate " data-date="" data-date-format="yyyy-mm-dd" >
								          <input class="form-control" value="<fmt:formatDate value="${assitems.startDate }" type="both" pattern="yyyy-MM-dd"/>" id="assItemsStartDate" name="assItemsStartDate" disabled="disabled"    size="10"  data-rule="required" type="text" />
					                   	 <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
				                	</div>
								</div>
							</div>
						</td>
						<td colspan="2">
							<div class="col-sm-12">
								<label for="guaranteeProfit_lab" class="col-sm-5 control-label">结束日期:</label>
								<div class="col-sm-7">
									<div class="input-group date endDate " data-date="" data-date-format="yyyy-mm-dd" >
								        <input class="form-control" id="assItemsEndDate" name="assItemsEndDate" disabled="disabled" value="<fmt:formatDate value="${assitems.endDate }" type="both" pattern="yyyy-MM-dd"/>" size="10"  data-rule="required" type="text" />
					                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
			                		</div>
								</div>
							</div>
						</td>
					</tr>
				</table>
				<div class="form-group">
					<label class="col-sm-2 control-label">备注:</label>
					<div class="col-sm-10">
						<textarea class="form-control required" rows="3" id="assItemsRemarks" name="assItemsRemarks">${assitems.remarks }</textarea>
					</div>
				</div>
			</div>
			<div class="modal-footer">
			 	<input type="hidden" id="updateAssitemsId"/>
			 	<c:if test="${flag != 'view' }">
					<button type="button" id="items_ok" class="btn btn-primary" onclick="addAssitemsRow()">确定</button>
				</c:if>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
	var start=0;
	var end=0;
	$('.startDate').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0,
		setLocalDate: new Date(2011, 2, 5),
		format: 'yyyy-mm-dd'
    }).on('changeDate',function(ev){
    	start = ev.date.valueOf();
    	
   });

	$('.endDate').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0,
		format: 'yyyy-mm-dd'	
    }).on('changeDate',function(ev){
    	  end = ev.date.valueOf();
    	
   });
</script>
</body>